package com.cubeofnine.sugar;

import com.cubeofnine.sugar.business.LoginBusiness;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

public class ForgotPasswordActivity extends ActivityImpt {
	private LoginBusiness loginBusiness = null;

	private EditText username = null;

	public static String getClassName() {
		return ForgotPasswordActivity.class.getName();
	}

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		Log.i(getClassName(), "onCreate() : Start");

		super.onCreate(savedInstanceState);
		setContentView(R.layout.forgot_password);
		try {
			loginBusiness = new LoginBusiness(this);

			username = (EditText) findViewById(R.id.text_forgot_username);
		} catch (Exception e) {
			Log.e(getClassName(), "onCreate()", e);
			alertDialog(R.string.msg_application_error);
		}

		Log.i(getClassName(), "onCreate() : End");
	}

	public void onClickResetButton(View view) {
		Log.i(getClassName(), "onClickResetButton() : Start");

		String usernameValue = username.getText().toString();
		Log.d(getClassName(), "usernameValue = " + usernameValue);

		if (usernameValue.length() == 0) {
			alertDialog(R.string.msg_username_not_empty);
		} else {
			try {
				boolean isValid = loginBusiness.checkUsernamePasswordFormat(
						usernameValue, "xxxxxxxx");// Not Check Password
				if (isValid) {
					// alertMessage(message, false);
				} else {
					alertDialog(R.string.msg_username_invalid);
				}
			} catch (Exception e) {
				Log.e(getClassName(), "onClickResetButton()", e);
				alertDialog(R.string.msg_application_error);
			}
		}

		Log.i(getClassName(), "onClickResetButton() : End");
	}
}
